package com.gongj.secuity.service;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;

@Service
public class HelloService {

    @PreAuthorize("hasRole('admin')")  //拥有admin权限
    public String admin() {
        return "hell admin";
    }

    @PreAuthorize("hasRole('user')")     //拥有user权限
    public String user() {
        return "hell user";
    }


    @PreAuthorize("hasAnyRole('admin','user')")  //拥有admin权限和user权限其中一个
    public String db() {
        return "hell db";
    }
}
